<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org" th:replace="demo/layout1" xmlns="http://www.w3.org/1999/html">
<div th:fragment="content">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <span>查看库存</span></br>
    <form action="#" th:action="@{/product/toXsKcY}" method="post">
        <label for="productid">商品名称：</label>
        <select data-placeholder="请选择商品" id="productid" name="productid" required>
            <option value="" selected>-商品名称-</option>
            <option  th:each="product:${productList}" th:value="${product.id}"  th:text="${product.productname}"></option>
            <p><input type="submit" value="查询"/></p>
        </select>

        <p>该商品的数量是：
        <p th:each="product:${pro}" th:value="${product.id}" th:text="${pro.quantity}"></p>
    </form>
    </body>
    <script  th:inline="javascript">
        $(function(){
            let productid = [[${productid}]];
            // alert(productid);
            $("#productid").val(productid);
        });
    </script>
</div>
</html>